﻿using System;
using UnityEngine;

namespace com.yoozoo.gta.Extension
{
    public class Rotation : MonoBehaviour
    {
        public Vector3 rotateSpeed = Vector3.zero;

        private Vector3 originalEulerAngles;

        public void StopAndReset()
        {
            this.rotateSpeed = Vector3.zero;
            this.transform.localEulerAngles = this.originalEulerAngles;
        }

        private void Start()
        {
            this.originalEulerAngles = this.transform.localEulerAngles;
        }

        private void Update()
        {
            if (this.rotateSpeed == Vector3.zero)
                return;

            this.transform.localEulerAngles += rotateSpeed * Time.deltaTime;
        }
    }
}